{% extends "base.html" %}

{% block title %}添加菜单 - 网站管理后台{% endblock %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">添加菜单</h1>
</div>

<div class="row">
    <div class="col-md-6">
        <form method="POST">
            <div class="mb-3">
                <label for="name" class="form-label">菜单名称</label>
                <input type="text" class="form-control" id="name" name="name" required>
            </div>
            <div class="mb-3">
                <label for="parent_id" class="form-label">父级菜单</label>
                <select class="form-control" id="parent_id" name="parent_id">
                    <option value="0">顶级菜单</option>
                    {% for menu in menus %}
                    <option value="{{ menu[0] }}">{{ menu[2] }}</option>
                    {% endfor %}
                </select>
            </div>
            <div class="mb-3">
                <label for="icon" class="form-label">图标类名</label>
                <input type="text" class="form-control" id="icon" name="icon">
                <div class="form-text">Font Awesome图标类名，如"fas fa-home"</div>
            </div>
            <div class="mb-3">
                <label for="path" class="form-label">路径</label>
                <input type="text" class="form-control" id="path" name="path">
            </div>
            <div class="mb-3">
                <label for="permission_id" class="form-label">关联权限</label>
                <select class="form-control" id="permission_id" name="permission_id">
                    <option value="">无权限要求</option>
                    {% for permission in permissions %}
                    <option value="{{ permission[0] }}">{{ permission[1] }} ({{ permission[2] }})</option>
                    {% endfor %}
                </select>
            </div>
            <div class="mb-3">
                <label for="sort_order" class="form-label">排序</label>
                <input type="number" class="form-control" id="sort_order" name="sort_order" value="0">
            </div>
            <button type="submit" class="btn btn-primary">添加菜单</button>
            <a href="{{ url_for('web.menus') }}" class="btn btn-secondary">取消</a>
        </form>
    </div>
</div>
{% endblock %}